package ch.zbw.sysventory.server.control.exceptions;

import java.io.IOException;
import java.io.Writer;

import freemarker.core.Environment;
import freemarker.template.TemplateException;

public class TemplateExceptionHandler implements freemarker.template.TemplateExceptionHandler {

	@Override
	public void handleTemplateException(TemplateException templateException, Environment env, Writer out) throws TemplateException {
		try {
			out.write("<div class=\"error\">[Error: " + templateException.getMessage() + "]</div>");
		} catch (IOException ex) {
			throw new TemplateException("Cannot write error message", env);
		}
	}

}
